<?php
	// Verify if the post have the right parameters
	if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['message'])) {
		// Set the parameters
		$to = "contato@rodrigocdellu.com.br";
		$subject = $_POST['subject'];
		$message = $_POST['message'];
		$header = "From:" . $_POST['name'] . "<" . $_POST['email'] . ">";
		$header .= "MIME-Version: 1.0\r\n";
		$header .= "Content-type: text/html\r\n";
		
		// Send the e-mail
		if (mail($to, $subject, $message, $header))
			// Encode as json for success
			echo json_encode(array('status' => 0));	
		else
			// Encode as json for error
			echo json_encode(array('status' => 1));
	}
?>
